import { reactive } from "vue";
import type { FormRules } from "element-plus";

/** 培训表单验证规则 */
export const formRules = reactive<FormRules>({
  title: [
    { required: true, message: "培训标题为必填项", trigger: "blur" },
    { min: 2, max: 100, message: "培训标题长度在 2 到 100 个字符", trigger: "blur" }
  ],
  category: [
    { required: true, message: "请选择培训分类", trigger: "change" }
  ],
  instructorName: [
    { required: true, message: "讲师姓名为必填项", trigger: "blur" },
    { min: 2, max: 20, message: "讲师姓名长度在 2 到 20 个字符", trigger: "blur" }
  ],
  level: [
    { required: true, message: "请选择培训级别", trigger: "change" }
  ],
  maxStudents: [
    { required: true, message: "最大学员数为必填项", trigger: "blur" },
    { type: "number", min: 1, max: 1000, message: "最大学员数必须在 1 到 1000 之间", trigger: "blur" }
  ],
  price: [
    { required: true, message: "培训价格为必填项", trigger: "blur" },
    { type: "number", min: 0, message: "培训价格不能为负数", trigger: "blur" }
  ],
  originalPrice: [
    { type: "number", min: 0, message: "原价不能为负数", trigger: "blur" }
  ],
  duration: [
    { required: true, message: "培训时长为必填项", trigger: "blur" },
    { type: "number", min: 1, message: "培训时长至少为 1 小时", trigger: "blur" }
  ],
  startTime: [
    { required: true, message: "请选择开始时间", trigger: "change" }
  ],
  endTime: [
    { required: true, message: "请选择结束时间", trigger: "change" }
  ],
  location: [
    { required: true, message: "培训地点为必填项", trigger: "blur" },
    { min: 2, max: 50, message: "培训地点长度在 2 到 50 个字符", trigger: "blur" }
  ],
  address: [
    { max: 200, message: "详细地址长度不能超过 200 个字符", trigger: "blur" }
  ],
  status: [
    { required: true, message: "请选择培训状态", trigger: "change" }
  ],
  tags: [
    { max: 100, message: "标签长度不能超过 100 个字符", trigger: "blur" }
  ],
  coverImage: [
    { max: 500, message: "封面图片URL长度不能超过 500 个字符", trigger: "blur" }
  ],
  description: [
    { required: true, message: "培训描述为必填项", trigger: "blur" },
    { min: 10, max: 1000, message: "培训描述长度在 10 到 1000 个字符", trigger: "blur" }
  ],
  content: [
    { max: 5000, message: "培训内容长度不能超过 5000 个字符", trigger: "blur" }
  ],
  requirements: [
    { max: 1000, message: "报名要求长度不能超过 1000 个字符", trigger: "blur" }
  ],
  objectives: [
    { max: 1000, message: "培训目标长度不能超过 1000 个字符", trigger: "blur" }
  ],
  schedule: [
    { max: 2000, message: "课程安排长度不能超过 2000 个字符", trigger: "blur" }
  ],
  materials: [
    { max: 1000, message: "培训材料长度不能超过 1000 个字符", trigger: "blur" }
  ],
  remark: [
    { max: 500, message: "备注长度不能超过 500 个字符", trigger: "blur" }
  ]
});